home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 May: Tool Chest / Dev.CD May 97 TC.toast / Sample Code / Overview / TESample / TESample.r < prev    next >
Encoding:
Text File  |  1994-11-18  |  7.9 KB  |  345 lines  |  [TEXT/MPS ]

  1. /*------------------------------------------------------------------------------
  2. #
  3. #    Apple Macintosh Developer Technical Support
  4. #
  5. #    MultiFinder-Aware TextEdit Sample Application
  6. #
  7. #    TESample
  8. #
  9. #    TESample.r    -    Rez Source
  10. #
  11. #    Copyright © 1989 Apple Computer, Inc.
  12. #    All rights reserved.
  13. #
  14. #    Versions:
  15. #                1.00                08/88
  16. #                1.01                11/88
  17. #                1.02                04/89
  18. #                1.03                06/89
  19. #                1.04                06/92
  20. #
  21. #    Components:
  22. #                TESample.p            June 1, 1989
  23. #                TESample.c            June 1, 1989
  24. #                TESampleInit.c        June 4, 1992
  25. #                TESampleGlue.a        June 1, 1989
  26. #                TESample.r            June 1, 1989
  27. #                TESample.h            June 1, 1989
  28. #                PTESample.make        June 1, 1989
  29. #                CTESample.make        June 1, 1989
  30. #                TCTESample.π        June 4, 1992
  31. #                TCTESample.π.rsrc    June 4, 1992
  32. #                TCTESampleGlue.c    June 4, 1992
  33. #
  34. #    TESample is an example application that demonstrates how 
  35. #    to initialize the commonly used toolbox managers, operate 
  36. #    successfully under MultiFinder, handle desk accessories and 
  37. #    create, grow, and zoom windows. The fundamental TextEdit 
  38. #    toolbox calls and TextEdit autoscroll are demonstrated. It 
  39. #    also shows how to create and maintain scrollbar controls.
  40. #
  41. #    It does not by any means demonstrate all the techniques you 
  42. #    need for a large application. In particular, Sample does not 
  43. #    cover exception handling, multiple windows/documents, 
  44. #    sophisticated memory management, printing, or undo. All of 
  45. #    these are vital parts of a normal full-sized application.
  46. #
  47. #    This application is an example of the form of a Macintosh 
  48. #    application; it is NOT a template. It is NOT intended to be 
  49. #    used as a foundation for the next world-class, best-selling, 
  50. #    600K application. A stick figure drawing of the human body may 
  51. #    be a good example of the form for a painting, but that does not 
  52. #    mean it should be used as the basis for the next Mona Lisa.
  53. #
  54. #    We recommend that you review this program or Sample before 
  55. #    beginning a new application. Sample is a simple app. which doesn’t 
  56. #    use TextEdit or the Control Manager.
  57. #
  58. ------------------------------------------------------------------------------*/
  59.  
  60. #include "systypes.r"
  61. #include "types.r"
  62.  
  63. #include "TESample.h"
  64.  
  65. resource 'vers' (1) {
  66.     0x02, 0x00, release, 0x00,
  67.     verUS,
  68.     "1.02",
  69.     "1.02, Copyright \251 1989 Apple Computer, Inc."
  70. };
  71.  
  72. /* we use an MBAR resource to conveniently load all the menus */
  73.  
  74. resource 'MBAR' (rMenuBar, preload) {
  75.     { mApple, mFile, mEdit };        /* three menus */
  76. };
  77.  
  78.  
  79. resource 'MENU' (mApple, preload) {
  80.     mApple, textMenuProc,
  81.     0b1111111111111111111111111111101,    /* disable dashed line, enable About and DAs */
  82.     enabled, apple,
  83.     {
  84.         "About TESample\311",
  85.             noicon, nokey, nomark, plain;
  86.         "-",
  87.             noicon, nokey, nomark, plain
  88.     }
  89. };
  90.  
  91. resource 'MENU' (mFile, preload) {
  92.     mFile, textMenuProc,
  93.     0b0000000000000000000100000000000,    /* enable Quit only, program enables others */
  94.     enabled, "File",
  95.     {
  96.         "New",
  97.             noicon, "N", nomark, plain;
  98.         "Open",
  99.             noicon, "O", nomark, plain;
  100.         "-",
  101.             noicon, nokey, nomark, plain;
  102.         "Close",
  103.             noicon, "W", nomark, plain;
  104.         "Save",
  105.             noicon, "S", nomark, plain;
  106.         "Save As\311",
  107.             noicon, nokey, nomark, plain;
  108.         "Revert",
  109.             noicon, nokey, nomark, plain;
  110.         "-",
  111.             noicon, nokey, nomark, plain;
  112.         "Page Setup\311",
  113.             noicon, nokey, nomark, plain;
  114.         "Print\311",
  115.             noicon, nokey, nomark, plain;
  116.         "-",
  117.             noicon, nokey, nomark, plain;
  118.         "Quit",
  119.             noicon, "Q", nomark, plain
  120.     }
  121. };
  122.  
  123. resource 'MENU' (mEdit, preload) {
  124.     mEdit, textMenuProc,
  125.     0b0000000000000000000000000000000,    /* disable everything, program does the enabling */
  126.     enabled, "Edit",
  127.      {
  128.         "Undo",
  129.             noicon, "Z", nomark, plain;
  130.         "-",
  131.             noicon, nokey, nomark, plain;
  132.         "Cut",
  133.             noicon, "X", nomark, plain;
  134.         "Copy",
  135.             noicon, "C", nomark, plain;
  136.         "Paste",
  137.             noicon, "V", nomark, plain;
  138.         "Clear",
  139.             noicon, nokey, nomark, plain
  140.     }
  141. };
  142.  
  143.  
  144. /* this ALRT and DITL are used as an About screen */
  145.  
  146. resource 'ALRT' (rAboutAlert, purgeable) {
  147.     {40, 20, 160, 296}, rAboutAlert, {
  148.         OK, visible, silent;
  149.         OK, visible, silent;
  150.         OK, visible, silent;
  151.         OK, visible, silent
  152.     };
  153. };
  154.  
  155. resource 'DITL' (rAboutAlert, purgeable) {
  156.     { /* array DITLarray: 5 elements */
  157.         /* [1] */
  158.         {88, 184, 108, 264},
  159.         Button {
  160.             enabled,
  161.             "OK"
  162.         },
  163.         /* [2] */
  164.         {8, 8, 24, 274},
  165.         StaticText {
  166.             disabled,
  167.             "MultiFinder-Aware TextEdit Application"
  168.         },
  169.         /* [3] */
  170.         {32, 8, 48, 237},
  171.         StaticText {
  172.             disabled,
  173.             "Copyright \251 1989 Apple Computer"
  174.         },
  175.         /* [4] */
  176.         {56, 8, 72, 136},
  177.         StaticText {
  178.             disabled,
  179.             "Brought to you by:"
  180.         },
  181.         /* [5] */
  182.         {80, 24, 112, 167},
  183.         StaticText {
  184.             disabled,
  185.             "Macintosh Developer  Technical Support"
  186.         }
  187.     }
  188. };
  189.  
  190.  
  191. /* this ALRT and DITL are used as an error screen */
  192.  
  193. resource 'ALRT' (rUserAlert, purgeable) {
  194.     {40, 20, 150, 260},
  195.     rUserAlert,
  196.     { /* array: 4 elements */
  197.         /* [1] */
  198.         OK, visible, silent,
  199.         /* [2] */
  200.         OK, visible, silent,
  201.         /* [3] */
  202.         OK, visible, silent,
  203.         /* [4] */
  204.         OK, visible, silent
  205.     }
  206. };
  207.  
  208.  
  209. resource 'DITL' (rUserAlert, purgeable) {
  210.     { /* array DITLarray: 3 elements */
  211.         /* [1] */
  212.         {80, 150, 100, 230},
  213.         Button {
  214.             enabled,
  215.             "OK"
  216.         },
  217.         /* [2] */
  218.         {10, 60, 60, 230},
  219.         StaticText {
  220.             disabled,
  221.             "Error. ^0."
  222.         },
  223.         /* [3] */
  224.         {8, 8, 40, 40},
  225.         Icon {
  226.             disabled,
  227.             2
  228.         }
  229.     }
  230. };
  231.  
  232.  
  233. resource 'WIND' (rDocWindow, preload, purgeable) {
  234.     {64, 60, 314, 460},
  235.     zoomDocProc, invisible, goAway, 0x0, "untitled"
  236. };
  237.  
  238.  
  239. resource 'CNTL' (rVScroll, preload, purgeable) {
  240.     {-1, 385, 236, 401},
  241.     0, visible, 0, 0, scrollBarProc, 0, ""
  242. };
  243.  
  244.  
  245. resource 'CNTL' (rHScroll, preload, purgeable) {
  246.     {235, -1, 251, 386},
  247.     0, visible, 0, 0, scrollBarProc, 0, ""
  248. };
  249.  
  250. resource 'STR#' (kErrStrings, purgeable) {
  251.     {
  252.     "You must run on 512Ke or later";
  253.     "Application Memory Size is too small";
  254.     "Not enough memory to run TESample";
  255.     "Not enough memory to do Cut";
  256.     "Cannot do Cut";
  257.     "Cannot do Copy";
  258.     "Cannot exceed 32,000 characters with Paste";
  259.     "Not enough memory to do Paste";
  260.     "Cannot create window";
  261.     "Cannot exceed 32,000 characters";
  262.     "Cannot do Paste"
  263.     }
  264. };
  265.  
  266. /* here is the quintessential MultiFinder friendliness device, the SIZE resource */
  267.  
  268. resource 'SIZE' (-1) {
  269.     dontSaveScreen,
  270.     acceptSuspendResumeEvents,
  271.     enableOptionSwitch,
  272.     canBackground,                /* we can background; we don't currently, but our sleep value */
  273.                                 /* guarantees we don't hog the Mac while we are in the background */
  274.     multiFinderAware,            /* this says we do our own activate/deactivate; don't fake us out */
  275.     backgroundAndForeground,    /* this is definitely not a background-only application! */
  276.     dontGetFrontClicks,            /* change this is if you want "do first click" behavior like the Finder */
  277.     ignoreChildDiedEvents,        /* essentially, I'm not a debugger (sub-launching) */
  278.     not32BitCompatible,            /* this app should not be run in 32-bit address space */
  279.     reserved,
  280.     reserved,
  281.     reserved,
  282.     reserved,
  283.     reserved,
  284.     reserved,
  285.     reserved,
  286.     kPrefSize * 1024,
  287.     kMinSize * 1024    
  288. };
  289.  
  290.  
  291. type 'MOOT' as 'STR ';
  292.  
  293.  
  294. resource 'MOOT' (0) {
  295.     "MultiFinder-Aware TextEdit Sample Application"
  296. };
  297.  
  298.  
  299. resource 'BNDL' (128) {
  300.     'MOOT',
  301.     0,
  302.     {
  303.         'ICN#',
  304.         {
  305.             0, 128
  306.         },
  307.         'FREF',
  308.         {
  309.             0, 128
  310.         }
  311.     }
  312. };
  313.  
  314.  
  315. resource 'FREF' (128) {
  316.     'APPL',
  317.     0,
  318.     ""
  319. };
  320.  
  321.  
  322. resource 'ICN#' (128) {
  323.     { /* array: 2 elements */
  324.         /* [1] */
  325.         $"04 30 40 00 0A 50 A0 00 0B 91 10 02 08 22 08 03"
  326.         $"12 24 04 05 20 28 02 09 40 10 01 11 80 0C 00 A1"
  327.         $"80 03 FF C2 7E 00 FF 04 01 00 7F 04 03 00 1E 08"
  328.         $"04 E0 00 0C 08 E0 00 0A 10 E0 00 09 08 C0 00 06"
  329.         $"04 87 FE 04 02 88 01 04 01 88 00 84 00 88 00 44"
  330.         $"00 88 00 44 00 88 00 C4 01 10 01 88 02 28 03 10"
  331.         $"01 C4 04 E0 00 02 08 00 73 BF FB EE 4C A2 8A 2A"
  332.         $"40 AA AA EA 52 AA AA 24 5E A2 8A EA 73 BE FB 8E",
  333.         /* [2] */
  334.         $"04 30 40 00 0E 70 E0 00 0F F1 F0 02 0F E3 F8 03"
  335.         $"1F E7 FC 07 3F EF FE 0F 7F FF FF 1F FF FF FF BF"
  336.         $"FF FF FF FE 7F FF FF FC 01 FF FF FC 03 FF FF F8"
  337.         $"07 FF FF FC 0F FF FF FE 1F FF FF FF 0F FF FF FE"
  338.         $"07 FF FF FC 03 FF FF FC 01 FF FF FC 00 FF FF FC"
  339.         $"00 FF FF FC 00 FF FF FC 01 FF FF F8 03 EF FF F0"
  340.         $"01 C7 FC E0 00 03 F8 00 73 BF FB EE 7F BE FB EE"
  341.         $"7F BE FB EE 7F BE FB E4 7F BE FB EE 73 BE FB 8E"
  342.     }
  343. };
  344.  
  345.